package com.itheima.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Application {
    //引入yml中对象.name对应属性
    @Value("${person.name}")
    private String name;
    @Value("${person.age}")
    private Integer age;
    //引入yml中数组0索引
    @Value("${person.address[0]}")
    private String address;
    @Autowired
    private Person person;
    @RequestMapping("/hello")
    public String  personValue() {
        //输出yml中对应属性注入的值
        System.out.println(name);
        System.out.println(age);
        System.out.println(address);
        System.out.println("====================");
        //打印实体类注入yml映射的对象属性
        String[] address = person.getAddress();
        System.out.println(person.getName());
        System.out.println(person.getAge());
        for (String s : address) {
            System.out.println(s);
        }
        return "Hello SpirngBoot ！！！";
    }
}
